package com.yy.cloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 购物车服务controller
 *
 * @date 2024/5/6
 */
@RestController
public class ShopCartController {

    @Value("${server.port}")
    private String serverPort;

    /**
     * 模拟根据购物车的id查询购物车详细信息
     *
     * @param cartId 购物车id
     * @return 购物车详情
     */
    @GetMapping("/shop-cart/{cartId}")
    public String cartItemDetail(@PathVariable("cartId") int cartId) {
        if (cartId < 1 || cartId > 10000) {
            return "查询购物项为空，当前服务的端口号为：" + serverPort;
        }
        String cartItem = "购物项：" + cartId;
        return cartItem + ",当前服务的端口号为：" + serverPort;
    }
}
